package com.zhuiyun.project.cyclingapplet.controller;


import com.alibaba.fastjson2.JSONObject;
import com.zhuiyun.project.cyclingapplet.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhuiyun.project.cyclingapplet.service.ILogonService;

import java.util.Map;

/**
 * @ClassName LogonController
 * @Description 用户登录类
 * @Author QiaoYuXin
 * @Date 2024/8/1 8:46
 **/
@RestController
@RequestMapping("/cyclingapplet/LogonPath")
public class LogonController {

    @Autowired
    ILogonService iLogonService;

    @RequestMapping("/Logon")
    public Map<String, Object> Logon(@RequestBody String jsonStr){
        JSONObject jsonObj = JSONObject.parseObject(jsonStr);
       //获取前端用户输入的电话号码
       String phone = jsonObj.getString("phone");
        //获取前端用户输入的密码
        String password = jsonObj.getString("password");
       // 新建对象，用于存储前端获取的信息
        SysUser sysUser = new SysUser();
        sysUser.setPhone(phone);
       sysUser.setPassword(password);

        System.out.println("123213213213"+sysUser.getPhone());

        System.out.println("sadsad");
        //新建对象，用于接收查询返回值，并且判断是否登录成功
        Map<String, Object> m  = iLogonService.logon(sysUser);
        System.out.println("asdasdasdsada");
        System.out.println("hhhh"+m.get("msg"));
        return m;
    }







}
